package com.avic.rong.activity.IncreaseTQ;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.avic.rong.BaseActivity;
import com.avic.rong.R;
import com.avic.rong.bean.increase_tp.IncreaseTpBean;
import com.avic.rong.questionOrAnswer.StringUtil;

import java.io.Serializable;
import java.lang.ref.WeakReference;

import butterknife.BindView;

public class NotThroughActivity extends BaseActivity {

    @BindView(R.id.tv_name)
    TextView tv_name;
    @BindView(R.id.tv_identify)
    TextView tv_identify;
    @BindView(R.id.tv_address)
    TextView tv_address;
    @BindView(R.id.tv_phone)
    TextView tv_phone;
    @BindView(R.id.tv_bank)
    TextView tv_bank;
    @BindView(R.id.tv_blankNo)
    TextView tv_blankNo;
    @BindView(R.id.btn_update)
    Button btn_update;
    @BindView(R.id.tv_why)//原因
    TextView tv_why;

    private IncreaseTpBean data;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_not_through;
    }

    @Override
    protected void initView() {
        tvTitle.setText("增票资质");
        ivRight.setBackgroundResource(R.mipmap.slh);

        data = (IncreaseTpBean) getIntent().getSerializableExtra("increaseFail");

        if (data!=null) {
            tv_name.setText(data.getCompanyName());
            tv_address.setText(data.getRegAddress());
            tv_bank.setText(data.getBank());
            tv_blankNo.setText(data.getBlankNo());
            tv_identify.setText(data.getIdentificationNumber());
            tv_phone.setText(data.getRegMobile());

            if (!StringUtil.isEmpty(data.getRemark())){
                tv_why.setText(data.getRemark());
            }
        }


    }

    @Override
    protected void addListener() {
        btn_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                upTp();//修改增票资质
            }
        });
    }

    private void upTp() {
        //跳转修改赠票资质
        Intent intent = UpIncreaseTpActivity.queryIntent(this);
        intent.putExtra("data", (Serializable) data);
        startActivity(intent);
    }

    public static Intent queryIntent(Context context){
        Intent intent = new Intent(context, NotThroughActivity.class);
        return intent;
    }

    private static WeakReference<NotThroughActivity> sActivityRef;

    public static void finishActivity() {
        if (sActivityRef != null && sActivityRef.get() != null) {
            sActivityRef.get().finish();
        }
    }


}
